
// #ifndef VUE3
import Vue from 'vue'
import App from './App'

import store from '@/store/store.js'

// 为了能够拦截请求，引入 @escook/request-miniprogram
import { $http } from '@escook/request-miniprogram'
// 将 $http 挂载到全局对象身上
uni.$http = $http

// 配置请求根路径
$http.baseUrl = 'https://www.uinav.com'

// 请求拦截
$http.beforeRequest = function (option) {
  uni.showLoading({
    title: '内容正在加载中...'
  })
  if(option.url.indexOf('/my/') !== -1) {
    option.header = {
      Authorization: store.state.m_user.token
    }
  }
}

// 响应拦截
$http.afterRequest = function() {
  uni.hideLoading()
}

// 绑定数据请求失败函数
uni.showMsg = function (title = '数据请求失败！', duration = 1500) {
  uni.showToast({
    title,
    duration,
    icon: 'none'
  })
}

Vue.config.productionTip = false

App.mpType = 'app'

const app = new Vue({
    ...App,
    store
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
import App from './App.vue'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
}
// #endif